package com.df.orderserver.api.order.controller;

import com.df.orderserver.base.BaseController;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @Author : lichong
 * @description :
 * @Date Create in 21:46 2020/5/11
 * @Modified By :
 **/
@RequestMapping("/api/order")
@RestController
public class OrderController extends BaseController {

    @Autowired
    private RestTemplate restTemplate;


    @GetMapping("/userInfo")
    @HystrixCommand(fallbackMethod = "errorStr")
    public String getUserInfo() {
        String userInfo = restTemplate.getForObject("http://USER-SERVER/api/user/info", String.class);
        return userInfo;
    }

    @GetMapping("/info")
    @HystrixCommand(fallbackMethod = "errorStr")
    public String getOrderInfo() {
        int i = 1 / 0;
        return "111111111111111111111";
    }
}
